import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class Test6 {
/*     public static void main(String[] args) {
        String s1="";
        String s2="1";
        String str=solve(s1,s2);
        System.out.println(str);
    }
   public static String solve (String s, String t) {
        // write code here
        String str=new String();
        int a=0;
        int b=0;
        int m=0;
        int n=0;
        for(int i=s.length()-1;i>=0;i--){
            a+=(s.charAt(i)-48)*Math.pow(10,n++);
        }
        for(int i=t.length()-1;i>=0;i--){
            b+=(t.charAt(i)-48)*Math.pow(10,m++);
        }
        int sum=(int)a*b;
        str+=sum;
        return str;
    }*/








    // 链表相加
      public static class ListNode {
        int val;
        ListNode next = null;
        public ListNode(int val) {
          this.val = val;
        }
     }
    public static void main02(String[] args) {
        ListNode head1=new ListNode(9);
        head1.next=new ListNode(3);
        head1.next.next=new ListNode(7);
        ListNode head2=new ListNode(6);
        head2.next=new ListNode(3);
        ListNode cur=addInList(head1,head2);
        while(cur!=null){
            System.out.print(cur.val+" ");
            cur= cur.next;
        }
    }
    public static ListNode addInList (ListNode head1, ListNode head2) {
        // write code here
        ListNode cur1=head1;
        ListNode cur2=head2;
        Stack<Integer> q1=new Stack<>();
        int count1=0;
        Stack<Integer> q2=new Stack<>();
        int count2=0;
        while(cur1 !=null){
            q1.add(cur1.val);
            count1++;
            cur1=cur1.next;
        }
        while(cur2 !=null){
            q2.add(cur2.val);
            count2++;
            cur2=cur2.next;
        }
        int n=(count1>count2)?count1:count2;
        ListNode curHead=null;
        // 用pur来记录进位
        Stack<Integer> pur=new Stack<>();
        pur.add(0);
        while(n!=0){
            // 用pop来记录当前位置的值
            int pop=0;
            if(q1.isEmpty()){
                pop+=q2.pop()+pur.peek();
            }else if(q2.isEmpty()){
                pop+= q1.pop()+pur.peek();
            }else{
                pop+=q1.pop()+ q2.pop()+pur.peek();
            }
            if(pop>=10){
                pur.add(1);
                pop%=10;
            }else{
                pur.add(0);
            }
            // 头插
            ListNode cur=new ListNode(pop);
            cur.next=curHead;
            curHead=cur;

            n--;
            if(n == 0){
                if(pur.peek()==1){
                    ListNode peek=new ListNode(pur.peek());
                    peek.next=curHead;
                    curHead=peek;
                }
            }
        }
        return curHead;
      }








    // 大数加法
    public static void main(String[] args) {
        String s1="114514";
        String s2="";
        String str=solve (s1,s2);
        System.out.println(str);
    }
    public static String solve (String s, String t) {
        // write code here
        String str=new String();
        int a=0;
        int b=0;
        int m=0;
        int n=0;
        for(int i=s.length()-1;i>=0;i--){
            a+=(s.charAt(i)-48)*Math.pow(10,n++);
        }
        for(int i=t.length()-1;i>=0;i--){
            b+=(t.charAt(i)-48)*Math.pow(10,m++);
        }
        int sum=(int)a+b;

        str+=sum;
        return str;
    }
}